/* GUI CONVERTED from ececrp2b.i (converter v1.75) Mon Aug 14 12:26:08 2000 */
/* ececrp2b.i - BOM SUMMARY SUB-ROUTINE                                  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                   */
/* All rights reserved worldwide.  This is an unpublished work.          */
/*V8:ConvertMode=Report                                                  */
/* REVISION: 5.0     LAST EDIT: 11/22/93      MODIFIED BY: QZL *H013*  */
/* REVISION: 7.4     LAST EDIT: 10/27/94      MODIFIED BY: ame *H578*  */
/* REVISION: 7.4     LAST EDIT: 04/20/95      MODIFIED BY: QZL *H0DB*  */
/* REVISION: 8.6E    LAST MODIFIED: 03/28/00   BY: *L0VJ* Jyoti Thatte     */
/* REVISION: 9.1     LAST MODIFIED: 08/14/00   BY: *N0KW* Jacolyn Neder    */





/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

     find first {1} where {1}.ps_par = comp no-lock no-error.

     repeat:
        if not available {1} then do:
        repeat:
           level = level - 1.
           if level < 1 then leave.
           find {1} where recid({1}) = record[level]
           no-lock no-error.
           comp = {1}.ps_par.
           qty = save_qty[level].
           if level = 1 then effstart = ?. else effstart =
           eff_start[level - 1].
           if level = 1 then effend   = ?. else effend   =
           eff_end[level - 1].
           find next {1} where {1}.ps_par = comp no-lock no-error.
           if available {1} then leave.
        end.
        end.

        if level < 1 then leave.

        par = {1}.ps_par.
        if {1}.ps_ps_code = "" and {1}.ps_qty_per <> 0 then do:
           find pt_mstr where pt_part = {1}.ps_comp no-lock no-error.
           if available pt_mstr then do:

          find first pk_det where pk_part = {1}.ps_comp and
          pk_reference = {1}.ps_ref and pk_user = mfguser and
          pk_start = max(if effstart
          = ? then low_date else effstart,
          if {1}.ps_start <> ? then {1}.ps_start
          else low_date) and pk_end   =
          min(if effend = ? then hi_date
          else effend, if {1}.ps_end <> ? then
          {1}.ps_end else hi_date) no-error.

          if not avail pk_det then do:
             create pk_det.
             assign pk_user = mfguser
             pk_part = {1}.ps_comp
             pk_user1 =  {1}.ps_par
             pk_ref   = {1}.ps_ref
             pk_start = max(if effstart = ? then low_date else effstart,
             if {1}.ps_start <> ? then {1}.ps_start else low_date)
             pk_end   = min(if effend = ? then hi_date else effend,
             if {1}.ps_end <> ? then {1}.ps_end else hi_date).
          end.

/*H0DB*/          if can-find(first ecd1_det where ecd1_nbr = ecmnbr and
/*H0DB*/          ecd1_par = {1}.ps_par and ecd1_comp = {1}.ps_comp)
/*H0DB*/          then pk_lot = "ECN".

/*L0VJ**  pk_qty  = pk_qty + {1}.ps_qty_per * qty *          */
/*L0VJ*/  pk_qty  = pk_qty + {1}.ps_qty_per_b * qty *
          (100 / (100 - {1}.ps_scrp_pct)).
           end.
        end.

        if ({1}.ps_ps_code = "" or {1}.ps_ps_code = "X")
        and {1}.ps_qty_per <> 0 and level < 1000 then do:

        record[level] = recid({1}).
        save_qty[level] = qty.

        eff_start[level] = max(effstart,{1}.ps_start).
        if effstart = ? then eff_start[level] = {1}.ps_start.
        if {1}.ps_start = ? then eff_start[level] = effstart.
        eff_end[level] = min(effend,{1}.ps_end).
        if effend   = ? then eff_end[level] = {1}.ps_end.
        if {1}.ps_end   = ? then eff_end[level] = effend.

        comp = {1}.ps_comp.
        find pt_mstr no-lock where pt_part = {1}.ps_comp no-error.
        if available pt_mstr and pt_bom_code <> "" then
        comp = pt_bom_code.

        qty = qty * {1}.ps_qty_per * (100 / (100 -
        {1}.ps_scrp_pct)).

        effstart = max(eff_start[level],{1}.ps_start).
        if eff_start[level] = ? then effstart = {1}.ps_start.
        if {1}.ps_start = ?         then effstart = eff_start[level].
        effend = min(eff_end[level],{1}.ps_end).
        if eff_end[level] = ?   then effend = {1}.ps_end.
        if {1}.ps_end = ?           then effend = eff_end[level].

        level = level + 1.
        find first {1} where {1}.ps_par = comp no-lock no-error.
        end.
        else find next {1} where {1}.ps_par = comp no-lock no-error.
     end.


/*H578* for each psmstr:*/
/*H578*/ for each psmstr exclusive: delete psmstr. end.
